package com.drojian.demo1.myself;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.drojian.demo.R;

public class MyTitleBar extends RelativeLayout {
    private ImageView titleBar_left;
    private TextView title;
    private Button titleBar_right;
    private RelativeLayout relativeLayout;
    private int color=R.color.black;


    public MyTitleBar(Context context) {
        super(context);
        initView(context);
    }

    public MyTitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public MyTitleBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    @SuppressLint("ResourceAsColor")
    private void initView(Context context){
        View view = LayoutInflater.from(context).inflate(R.layout.title_bar, this, true);
        titleBar_left = view.findViewById(R.id.titleBack);
        title = view.findViewById(R.id.titleText);
        titleBar_right = view.findViewById(R.id.titleEdit);
        relativeLayout = view.findViewById(R.id.RelativeLayout2);
        title.setTextColor(Color.BLACK);
    }

    public void  left_onClick(OnClickListener onClickListener){
        titleBar_left.setOnClickListener(onClickListener);
    }

    public void  right_onClick(OnClickListener onClickListener){
        titleBar_right.setOnClickListener(onClickListener);
    }

    public void setTitle(String titleName){
        if(!TextUtils.isEmpty(titleName)){
            title.setText(titleName);
        }
    }

}
